var a = function(a) {
    if (a && a.__esModule) return a;
    var t = {};
    if (null != a) for (var e in a) Object.prototype.hasOwnProperty.call(a, e) && (t[e] = a[e]);
    return t.default = a, t;
}(require("../../components/card-scanner-form/card-scanner")), t = [ "#000000", "#42c642" ];

Page({
    data: {
        canUseCamera: wx.canIUse && wx.canIUse("camera")
    },
    onLoad: function() {
        this.changeNavColor(t[this.data.canUseCamera ? 0 : 1]);
    },
    changeNavColor: function(a) {
        wx.setNavigationBarColor({
            backgroundColor: a,
            frontColor: "#ffffff"
        });
    },
    onSuccess: function(a) {
        var t = a.detail.file;
        this.request(t);
    },
    request: function(t) {
        var e = this;
        this.setData({
            file: t,
            loading: !0
        }), a.ocr(t).then(function(a) {
            e.$put("card.scan.data", {
                data: a,
                file: t
            }), wx.redirectTo({
                url: "/pages/components/card-scanner/card-scanner"
            });
        }).catch(this.fail);
    },
    fail: function(a) {
        this.setData({
            file: "",
            loading: !1
        });
    },
    onFail: function() {
        this.changeNavColor(t[1]), this.setData({
            canUseCamera: !1
        });
    },
    takeShot: function(t) {
        var e = t.currentTarget.dataset.type;
        a.chooseImage(e).then(this.request);
    }
});